package com.xcdh.orm.util;

import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.druid.pool.DruidDataSource;
import com.xcdh.commons.encrypt.AESCoder;
import com.xcdh.orm.entity.OrmDataSource;
import lombok.SneakyThrows;

import java.util.HashMap;
import java.util.Map;

public class DBServiceUtil {

    @SneakyThrows
    public static DruidDataSource createDs(OrmDataSource ds){
        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(ds.getDriver());
        druidDataSource.setUrl(ds.getUrl());
        druidDataSource.setUsername(AESCoder.decrypt(ds.getUserName()));
        druidDataSource.setPassword(AESCoder.decrypt(ds.getPassword()));
        druidDataSource.setTestWhileIdle(false);
        return druidDataSource ;
    }


}
